package com.qingcheng.controller.goods;

import com.alibaba.dubbo.config.annotation.Reference;
import com.qingcheng.service.goods.BrandService;
import com.qingcheng.service.goods.SpecService;
import com.qingcheng.service.order.TradeReportService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 定时缓存任务
 */
@Component
public class OrderTask {

    @Reference
    private BrandService brandService;

    @Reference
    private SpecService specService;

    /**
     * 定时缓存品牌信息到redis
     */
    @Scheduled(cron = "0 0 1/4 * * ?")
    public void saveBrandByCategoryToRedis(){ //每天晚上1点到4点执行一次任务
        System.out.println("缓存品牌信息到redis");
        brandService.saveBrandByCategoryToRedis();
    }

    /**
     * 定时缓存规格信息到redis
     */
    @Scheduled(cron = "0 0 1/4 * * ?")
    public void saveSpecByCategoryToRedis(){ //每天晚上1点到4点执行一次任务
        System.out.println("缓存规格信息到redis");
        specService.saveSpecByCategoryToRedis();
    }


}
